<HTML><HEAD>
<!--
    -----------------
    Host details
    -----------------


    THE JAVASCRIPT COOKBOOK by Erica Sadun, webrx@mindspring.com
							   J. Brook Monroe, mrprogguy@techie.com
    Copyright (c)2000 by Charles River Media.  All Rights Reserved.
    
    This applet can only be re-used or modifed by license holders of the
    JavaScript Cookbook CD-ROM.  Credit must be given in the source
    code and this copyright notice must be maintained. If you do
    not hold a license to the JavaScript Cookbook, you may NOT
    duplicate or modify this code for your own use.

    Use at your own risk. No warranty is given or implied of the suitability 
    of this applet for any specific application. Neither Erica Sadun nor 
    Charles River Media will be held responsible for any unwanted effects 
    due to the use of this applet or any derivative. 

-->
<BODY bgcolor="ffffff" link="0000ff" vlink="770077">
    
<FONT COLOR="007777"><H1><IMG SRC="../GRAFX/UTENS.JPG" WIDTH=80 HEIGHT=50
ALIGN = LEFT>Who's Hosting This Party?</H1></FONT>
<BLOCKQUOTE><FONT COLOR="770000">
        This script displays information
        about the current document.<p>
    </FONT></BLOCKQUOTE>
<FONT FACE="Arial,Helvetica" SIZE="2">
<UL><LI>The current document is
<SCRIPT LANGUAGE="JavaScript"><!--
document.write('<i> '+document.location.href+'</i>');
//--></SCRIPT>.</LI><BR>
<LI>The current document host is
<SCRIPT LANGUAGE="JavaScript">
<!--
var h = document.location.hostname;
if(h == '')
	document.write(' the local computer');
else
	document.write('<i> '+document.location.hostname+'</i>');
//--></SCRIPT>.
</FONT></LI></UL><BR><BR>(If the results are <i>undefined</i> then your browser version doesn't support this feature.)
<FONT COLOR="007777"><H2>Discussion</H2></FONT>
<FONT SIZE=4>
Sometimes it's interesting to know what the current document name is, as well as from where
it was loaded.  (Perhaps it's a way to see if someone is "borrowing" your scripts!)<BR><BR>
When the <FONT color=770000">hostname</FONT> property of a document is empty, the document was loaded from the
local computer (as opposed to coming from an HTTP server somewhere).  Armed with this knowledge,
you can add debugging code to your scripts which the end-user will never ordinarily see, but
which will assist you in developing a bug-free script on your home computer before posting it
for the world to see:
<BR>
</FONT>
<PRE><FONT color="#770000">
	<SCRIPT LANGUAGE="JavaScript">

	var inDebug = document.location.hostname=="";

	function countDelimiters(inString,inDelim)
	{
	    var ret = 0;
	<FONT COLOR="#007700">    if(inDebug)
		    alert('Incoming string is ['+inString+']\nSearching for ['+inDelim+']');</FONT>
	    for(var i = 0; i < inString.length; i++)
	        if(inString.charAt(i) == inDelim)
	            ret++;
	    return ret;
	}

	</SCRIPT>

</FONT>
<BR><BR><h5>Copyright ©2000 by Charles River Media, All Rights Reserved</h5>
</BODY>
</HTML>